home *** CD-ROM | disk | FTP | other *** search
- { SPX Library Version 3.0 Copyright 1993 Scott D. Ramsay }
-
- The SPX_T3D is the basic 3D and angle unit. It contains
- a sine/cosine table as well as simple rotation functions in 2D and 3D.
- This unit is very simpilfied to keep the math from you ;)
-
- GLOBAL VARIABLES:
-
- xc,yc: Origin point (0,0,0) for 3D routines on the screen
- Default: xc=160 yv=100 (center of VGA screen)
- xv,yv,zv: Viewer's position. Location point of your eye
- Default: xv=0 yv=-10 zv=150
- sx,sy,sz: Scale factors. Values to scale each 3D plot.
- Default: sx=1 sy=1 sz=1
- sine,cosine: Sine and Cosine look up tables from 0 to 255.
-
- sine[i] := sin(2*3.141592653/256*i)*256;
- cosine[i] := cos(2*3.141592653/256*i)*256;
-
- ───────────────────────────────────────────────────────────────────────────
- procedure setpoints(xx,yy,zz:longint; var xd,yd : integer);
-
- Converts a 3D point to a 2D screen point.
-
- XX,YY,ZZ: (x,y,z) 3D point;
- XD,YD: converted (x,y) 2D point
-
- XD,YD can be affected by SX, SY, SZ, XV, YV, ZV, XC, YC
-
- ───────────────────────────────────────────────────────────────────────────
- procedure pset3d(xx,yy,zz:integer;n:byte);
-
- Draw a point.
-
- XX,YY,ZZ: (x,y,z) 3D point;
- N: Color of point
-
- ───────────────────────────────────────────────────────────────────────────
- procedure line3d(x1,y1,z1,x2,y2,z2:integer;n:byte;clip:boolean);
-
- Draw a line. Clips the line according to
- WinMinX, WinMinY, WinMaxX, WinMaxY.
-
- X1,Y1,Z1: Coordinate 1 of line;
- X2,Y2,Z2: Coordinate 2 of line;
- N: Color of line
- CLIP: If set to TRUE, the line will be clipped according to
- WinMinX, WinMinY, WinMaxX, WinMaxY.
-
- NOTE: CLIP=FALSE is faster.
- ───────────────────────────────────────────────────────────────────────────
- procedure rotate256xy(var x,y:integer;angle:byte);
-
- Rotates a 2D point (x,y) about the origin (0,0).
-
- X,Y: Point to rotate;
- ANGLE: Amount to rotate. Legal values: 0..255
-
- ───────────────────────────────────────────────────────────────────────────
- procedure rotate256xyz(var x,y,z:integer;xa,ya,za:byte);
-
- Rotates a 3D point (x,y,z) about the origin (0,0,0).
-
- X,Y,Z: Point to rotate;
- XA: Amount to rotate on the x-axis. Legal values: 0..255;
- YA: Amount to rotate on the y-axis. Legal values: 0..255;
- ZA: Amount to rotate on the z-axis. Legal values: 0..255
-
- ───────────────────────────────────────────────────────────────────────────
- function CalculateAngle(x1,y1,x2,y2:integer):integer;
-
- Finds the angle of the of the line (x1,y1,x2,y2) in numeric coordinates:
- [0..512].
-
- Shift right the return by 1 (div 2) to use with the predefined sine and
- cosine tables.
-
- ───────────────────────────────────────────────────────────────────────────
- function LinesIntersect(x1,y1,x2,y2,x3,y3,x4,y4:longint;var x,y:longint):integer;
-
- Does a fast check to see if the lines:
-
- line(x1,y1,x2,y2);
- line(x3,y3,x4,y4);
-
- Intersect
-
- Returning values:
-
- 0 do no intersect
- 1 do intersect, x,y contains the pixel value where they intersect
- 2 the lines are parallel
-
- ───────────────────────────────────────────────────────────────────────────